setGlobalDuration(15)

example = 4

if example == 1:
    freqMod(pitch=[50,100,200,300,400,800], modulator=[.498,.249, .75], amplitude=.2, index=10)

elif example == 2:
    a = genLineseg([0, 1, 1, 2, .7, 10, .1, 50, .3, 200, .1])
    readTable(bus='env', table=a)
    freqMod(pitch=[50,100,200,300,400,800], modulator=[.498,.249, .75], amplitude=.2, 
            index=10, indexVar='env', amplitudeVar='env')

elif example == 3:
    a = genLineseg([0, 1, 1, 2, .7, 10, .1, 50, .3, 200, .1])
    readTable(bus='env', table=a)
    freqMod(pitch=[50,100,200,300,400,800], modulator=[.498,.249, .75], amplitude=.2, 
            index=10, indexVar='env', amplitudeVar='env', out='fm')
    sine(pitch=[3,4], amplitude=1, pan=[0,1], out='sine')
    ringMod('fm', 'sine')

elif example == 4:
    a = genLineseg([0, 1, 1, 2, .7, 10, .1, 50, .3, 200, .1])
    readTable(bus='env', table=a)
    randomi(bus=[1,2,3,4,5,6], mini=0.98, maxi=1.02, rate=[4.5,4.1,4.7,4.34,4.28,5.1])
    freqMod(pitch=[50,100,200,300,400,800], modulator=[.498,.249, .75], amplitude=.2, 
            index=10, modulatorVar=[1,2,3,4,5,6], indexVar='env', amplitudeVar='env', out='fm')
    sine(pitch=[3,4], amplitude=1, pan=[0,1], out='sine')
    ringMod('fm', 'sine')
    
startCsound()